/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: 沈小白 2020-07-22 $
 */<template> 
	<view v-if="recommend.length>0">
		<image :src="imgUrl+'index/feature.png'" mode="" class="feature_title_bg"></image>
		 <view  class="choice_box">
		        <view class="choice_list choice_list_2">
		            <block v-for="(item,index) in recommend" :key="index">
		                <navigator :url="'/pages/goods/goodsInfo/goodsInfo?goods_id='+ item.goods_id">
		                    <view class="choice_item">
									<image :src="hostUrl+'/mall/goods/thumb_image?goods_id='+ item.goods_id+'&width='+goodsImgWidth+'&height='+goodsImgHeight+'&'+item.goods_id+'.'+imgType"></image>
		                            <!-- <image :src="hostUrl+item.original_img"></image> -->
		                        
		                        <view class="choice_footer">
		                            <view class='goods_name'>{{item.goods_name}}</view>
		                             <!-- 暂时先隐藏 -->
		                            <view style='display:none;' class='pro-label'>
		                                <view>商品标签</view>
		                                <view>商品标签</view>
		                            </view>
		                            <view class="goods_name_cen">
		                              <view class="des_flex_4">
		                                <view class="price">￥<text>{{item.shop_price.toFixed(2)}}</text></view>
		                                <view class="similer">
		                                    <text>已售{{item.show_sale_sum}}件</text>
		                                </view>
		                              </view>
		                            </view>
		                        </view>
		                    </view>
		                </navigator> 
		            </block>
		        </view>
		    </view>
	</view>
</template>

<script>
	import {getRecommendation} from "@/api/api.js";
	import config from "@/api/config.js";
	import {mapState} from "vuex";
	export default {
		
		data() {
			return {
				hostUrl:config.host,
				imgUrl:config.imgUrl,
				recommend:"",
			};
		},
		computed: {
			...mapState(['goodsImgWidth','goodsImgHeight','imgType'])
		},
		created(){
			this._getRecommendation()
			// console.log(config.host)
		},
		methods:{
			_getRecommendation(){
				getRecommendation().then(res=>{
					// console.log(res)
					this.recommend=res.records
				})
			}
		}
	}
</script>

<style lang="scss">
	.feature_title_bg{
		width: 750rpx;
		height: 80rpx;
	}
	
	.choice_box .choice_list .choice_item{
	    width:710rpx;
	    height: 220rpx;
	    margin:20rpx 0 0 20rpx;
	    background: #fff;
	    position: relative;
	    border-radius: 10rpx;
	    overflow: hidden;
	    display: inline-block;
	}
	.choice_box .choice_list image {
	    width: 220rpx;
	    height: 220rpx;
	}
	.choice_box .choice_list .choice_footer {
	    display: block; 
	    position: absolute;
	    line-height: 17rpx;
	    left: 220rpx;
	    top: 0;
	}
	.choice_list .choice_footer{
	    float:right;
	    width: 490rpx;
	    height:220rpx;
	    padding:14rpx 20rpx;
	    box-sizing: border-box;
	    background-color:#fff;
	    position:relative;
	}
	.choice_list_1{
	  margin-top: 20rpx;
	}
	.choice_list_2 navigator:last-child .choice_item{
	  margin-bottom: 20rpx; 
	}
	.choice_list .choice_footer .goods_name{
	    height:auto;
	    line-height:36rpx;
	    text-align:left;
	    color:#333;
	    font-size:26rpx;
	    overflow:hidden;
	    text-overflow:ellipsis;
	    display: -webkit-box;
	    -webkit-box-orient:vertical;
	    -webkit-line-clamp:2;
	    box-sizing: border-box;
	}
	.goods_name_cen{
	  position: absolute;
	  bottom: 0;
	  left: 0;
	  right: 0;
	  padding: 30rpx 20rpx 20rpx;
	  height: auto;
	  box-sizing: border-box;
	  width: 100%;
	  line-height: 32rpx;
	}
	.goods_name_cen .des_flex_4{
	  display: flex;
	  align-items: center;
	  justify-content: space-between;
	  width: 100%;
	}
	.goods_name_cen .goods_name{
	  max-width: 180rpx;
	  font-size: 28rpx;
	  font-weight: bold;
	}
	.goods_name_cen .price {
	  color: $text-color-master;
	  font-size: 22rpx;
	  font-weight: bold;
	  position: unset !important;
	}
	.goods_name_cen .price text{
	  font-size: 28rpx !important;
	}
	.goods_name_cen .similer{
	  height: auto;
	  line-height: 36rpx;
	  max-width: 180rpx;
	  font-size: 22rpx;
	  color: $text-color-hint;
	  position: unset !important;
	}
	.choice_list .choice_footer .goods_name{
	    height:auto;
	    line-height:36rpx;
	    text-align:left;
	    color:$text-color;
	    font-size:26rpx;
	    overflow:hidden;
	    text-overflow:ellipsis;
	    display: -webkit-box;
	    -webkit-box-orient:vertical;
	    -webkit-line-clamp:2;
	    box-sizing: border-box;
	}
	.choice_list .choice_footer .price {
	    color:$text-color-master;
	    font-size:22rpx;
	    font-weight:600;
	    position:absolute;
	    bottom:62rpx;
	}
	.choice_footer .price {
	    font-size: 30rpx;
	}
</style>
